package com.edu.glutdataconvertserver.config.mysql;

import com.edu.glutdataconvertserver.servicce.KwXqbService;
import org.springframework.stereotype.Component;

/**
 * Created by Hua wb on 2018/7/26.
 * 策略
 */
@Component
public class XqbjStrategy implements Strategy {

    private KwXqbService kwXqbService;

    @Override
    public String returnTableName(String tableName) {
        init();
        String xqbj = kwXqbService.selNowXq().getXqbh();
        StringBuilder sb = new StringBuilder(tableName);
        sb.append("_");
        sb.append(xqbj);
        return sb.toString();
    }

    private void init() {
        if (kwXqbService == null) {
            kwXqbService = SpringContextHolder.getBean(KwXqbService.class);
        }
    }
}
